var app = getApp();
var api = require('../../../config/api.js');
var util = require('../../../utils/util.js');

Page({
  data: {
    status: -1,
    list: [],
    hidden: -1,
    is_no_more: !1,
    is_loading: false,
    page:1
  },
  onLoad: function(t) {
    this.GetList(-1,1);
  },
  GetList: function(t,p) {
    var a = this;
    a.setData({
      status: parseInt(t || -1),
      page: parseInt(p || 1)
    }), wx.showLoading({
      title: "正在加载",
      mask: !0
    }), util.request(api.order, {
      status: a.data.status,
      page: a.data.page
    }).then(function(res) {
      wx.hideLoading();
      console.log(res.data.length);
      var y = a.data.list.concat(res.data);
      a.setData({
        list: y,
      })
      if (5 > res.data.length) {
        a.setData({
          is_loading: true
        })
      } else {
        a.setData({
          is_loading: false
        })
      }
    }).catch(() => {
      wx.hideLoading();
      wx.showModal({
        title: '注意',
        content: '服务器出小差了，请稍候重试.',
        showCancel: false
      });
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  click: function(t) {
    var a = t.currentTarget.dataset.index;
    this.setData({
      hidden: this.data.hidden == a ? -1 : a
    });
  },
  onReachBottom: function() {
    var i = this;
    if (i.data.is_loading==false){
      var p = i.data.page+1

      i.setData({
        page: p
      })
      this.GetList(-1, p);
     
    }
  }
});